package com.sskj.mine.asset;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.asset.data.AddresAllBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.presenter.BasePresenter;


/**
 * @author Hey
 * Create at  2019/05/04
 */
class AddressListPresenter extends BasePresenter<AddressListActivity> {


    /**
     * 提币地址列表
     *
     * @return
     */
    public void addressList() {
        httpService.addressList().execute(new JsonCallBack<HttpData<AddresAllBean>>(this) {
            @Override
            public void onSuccess(Response<HttpData<AddresAllBean>> response) {
                HttpData<AddresAllBean> httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {
                    mView.updateUI(httpData.getData());
                }
            }
        });
    }

    public void delete(String id) {
        httpService.deleteAddress(id)
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.deleteSuccess();
                        }
                    }
                });
    }

}
